import re

#1. 获取字符串'11:12:11> 001 enter chatroom，leve12'中的用户id和等级


# str1='11:12:11> 001 enter chatroom, leve12'
# id=str1[10:10 +3]
# leavel=str1[30:30 +6]
# print('id:{} 等级为:{}'.format(id,leavel))

# 2.获取下面字符串中的所有用户id和等级
# '''11:12:11> 001 enter chatroom，leve1211:12:11>22 enter chatroom，leve13
# 11:12:11>0004 enter chatroom，leve110511:12:11>003 enter chatroom，leve199'''
str2='''11:12:11> 001 enter chatroom，level12
    11:12:11>22 enter chatroom，level13
    11:12:11>0004 enter chatroom，level105
    11:12:11>003 enter chatroom，level199'''

l1=re.findall("(\d+ )|([1l]evel\d+)",str2)
print(l1)
# list1=str2.split('\n')
# list2=[]
# for i in list1:
#     i=i.split()
#     list2.append([i[1],i[4]])
# print(list2)



# 练习1∶从字符串“site sea sue sweet see case sse ssee loses”中匹配出所有s开头，e结尾的单词
str3="site sea sue sweet see case sse ssee loses"
pateen=r'\bs\w{1,5}e\b'
infor=re.findall(r'\bs\w*e\b',str3)
print(infor)